package com.hmall.order.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;



@Configuration
public class RabbitMqConfig {
    @Bean
    public TopicExchange ttlTopicExchange() {
        return new TopicExchange("ttl.topic");
    }

    @Bean
    public Queue ttlQueue() {
        return QueueBuilder
                .durable("ttl.queue")
                .ttl(60 * 1000) //todo 测试一分钟
                .deadLetterExchange("dl.topic")
                .deadLetterRoutingKey("dl")
                .build();
    }

    @Bean
    public Binding ttlBinding() {
        return BindingBuilder.bind(ttlQueue()).to(ttlTopicExchange()).with("ttl");
    }
}
